Change in openvpn[master]: [WIP] Do not access interal of ASN1_INTEGER to print hex of serial
A message that is not in the archive (sent off-list or not yet received): gerrit.1774445432000.I5158fbb0762443ea4954e5745f520e83e019ed30@...2715...
plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: [WIP] Do not access interal of ASN1_INTEGER to print hex of serial
......................................................................
[WIP] Do not access interal of ASN1_INTEGER to print hex of serial
OpenSSL 4.0 does not allow internal access to to these data structures anymore. So use public methods to get the serial data and convert it to hex.
TODO: check this does not change the output format
---
M src/openvpn/ssl_verify_openssl.c
1 file changed, 17 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/1589/1
src/openvpn/ssl_verify_openssl.c +17 -6
@@ -255,17 +255,19 @@ }else if (strcmp (LN_serialNumber, x509_username_field) ==0 ) { -ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); -struct gc_arena gc =gc_new (); -char *serial =format_hex_ex (asn1_i->data, asn1_i->length,0 ,1 |FHE_CAPS ,NULL , &gc); +const ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); + +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +char *serial =BN_bn2hex (bn_serial); +BN_free (bn_serial);if (!serial || cn_len <=strlen (serial) +2 ) { -gc_free (&gc); +OPENSSL_free (serial);return FAILURE ; }snprintf (common_name, cn_len,"0x%s" , serial); -gc_free (&gc); +OPENSSL_free (serial); }else {
@@ -310,8 +312,17 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) {const ASN1_INTEGER *asn1_i =X509_get_serialNumber (cert); +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +int len_serial =BN_num_bytes (bn_serial); +unsigned char *buf =malloc (len_serial); +BN_bn2binpad (bn_serial, buf, len_serial); -return format_hex_ex (asn1_i->data, asn1_i->length,0 ,1 ,":" , gc); + +char *ret =format_hex_ex (buf, len_serial,0 ,1 ,":" , gc); +free (buf); +BN_free (bn_serial); + +return ret; } result_t
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveplaisthos has uploaded a new patch set (#2). ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Do not access internals of ASN1_INTEGER to print hex of serial
OpenSSL 4.0 does not allow internal access to to these data structures anymore. So use public methods to get the serial data and convert it to hex.
---
M src/openvpn/ssl_verify_openssl.c
1 file changed, 16 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/1589/2
src/openvpn/ssl_verify_openssl.c +16 -6
@@ -255,17 +255,19 @@ }else if (strcmp (LN_serialNumber, x509_username_field) ==0 ) { -ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); -struct gc_arena gc =gc_new (); -char *serial =format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 |FHE_CAPS ,NULL , &gc); +const ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); + +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +char *serial =BN_bn2hex (bn_serial); +BN_free (bn_serial);if (!serial || cn_len <=strlen (serial) +2 ) { -gc_free (&gc); +OPENSSL_free (serial);return FAILURE ; }snprintf (common_name, cn_len,"0x%s" , serial); -gc_free (&gc); +OPENSSL_free (serial); }else {
@@ -310,8 +312,16 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) {const ASN1_INTEGER *asn1_i =X509_get_serialNumber (cert); +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +int len_serial =BN_num_bytes (bn_serial); +unsigned char *buf =malloc (len_serial); +BN_bn2binpad (bn_serial, buf, len_serial); -return format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 ,":" , gc); +char *ret =format_hex_ex (buf, len_serial,0 ,1 ,":" , gc); +free (buf); +BN_free (bn_serial); + +return ret; } result_t
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Patch Set 4:
(1 comment)
File src/openvpn/ssl_verify_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1589/comment/f70e7e3e_124725d2?usp=email :
PS4, Line 320: char *ret = format_hex_ex(buf, len_serial, 0, 1, ":", gc);
So why can't we use BN_bn2hex here?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Wed, 01 Apr 2026 10:41:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: flichtenheld.
plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Patch Set 4:
(1 comment)
File src/openvpn/ssl_verify_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1589/comment/07c2a8e3_08873e9b?usp=email :
PS4, Line 320: char *ret = format_hex_ex(buf, len_serial, 0, 1, ":", gc);
Quoted 1 line
So why can't we use
BN_bn2hexhere?
I changed this to use BN_bn2hex only to find out that then test fails since we have : in the output and BN_bn2hex does not.
[ ERROR ] --- "826BDDCCBDE55EB708F12D68003C24DE" != "82:6b:dd:cc:bd:e5:5e:b7:08:f1:2d:68:00:3c:24:de"
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 01 Apr 2026 11:53:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: flichtenheld.
plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Patch Set 4:
(1 comment)
File src/openvpn/ssl_verify_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1589/comment/c7682b24_7bdda5a6?usp=email :
PS4, Line 320: char *ret = format_hex_ex(buf, len_serial, 0, 1, ":", gc);
Quoted 1 line
I changed this to use
BN_bn2hexonly to find out that then test fails since we have : in the output […]
For reference the change with BN_bn2hex:
/** Wrapper around OpenSSL_free
*
* Passing OPENSSL_free to gc_add_special does not work
* since OPENSSL_free is a macro, so use this small wrapper
* to allow passing this function instead */
static voidopensl_free_wrapper(void *arg)
{
OPENSSL_free(arg);
}char *backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc)
{
const ASN1_INTEGER *asn1_i = X509_get_serialNumber(cert);
BIGNUM *bn_serial = ASN1_INTEGER_to_BN(asn1_i, NULL);
char *ret = BN_bn2hex(bn_serial);
gc_addspecial(ret, opensl_free_wrapper, gc);
BN_free(bn_serial);
return ret;
}--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 01 Apr 2026 11:54:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Patch Set 5: Code-Review+2
(1 comment)
File src/openvpn/ssl_verify_openssl.c:
http://gerrit.openvpn.net/c/openvpn/+/1589/comment/ff897ba8_973ab117?usp=email :
PS4, Line 320: char *ret = format_hex_ex(buf, len_serial, 0, 1, ":", gc);
Quoted 1 line
For reference the change with
BN_bn2hex: […]
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Wed, 01 Apr 2026 12:29:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: plaisthos <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
PATCH v5 1/1 Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
OpenSSL 4.0 does not allow internal access to to these data structures anymore. So use public methods to get the serial data and convert it to hex.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589
This mail reflects revision 5 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>
src/openvpn/ssl_verify_openssl.c +16 -6
@@ -260,17 +260,19 @@ }else if (strcmp (LN_serialNumber, x509_username_field) ==0 ) { -ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); -struct gc_arena gc =gc_new (); -char *serial =format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 |FHE_CAPS ,NULL , &gc); +const ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); + +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +char *serial =BN_bn2hex (bn_serial); +BN_free (bn_serial);if (!serial || cn_len <=strlen (serial) +2 ) { -gc_free (&gc); +OPENSSL_free (serial);return FAILURE ; }snprintf (common_name, cn_len,"0x%s" , serial); -gc_free (&gc); +OPENSSL_free (serial); }else {
@@ -315,8 +317,16 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) {const ASN1_INTEGER *asn1_i =X509_get_serialNumber (cert); +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +int len_serial =BN_num_bytes (bn_serial); +unsigned char *buf =malloc (len_serial); +BN_bn2binpad (bn_serial, buf, len_serial); -return format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 ,":" , gc); +char *ret =format_hex_ex (buf, len_serial,0 ,1 ,":" , gc); +free (buf); +BN_free (bn_serial); + +return ret; } result_t
PATCH v5 1/1 Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
OpenSSL 4.0 does not allow internal access to to these data structures anymore. So use public methods to get the serial data and convert it to hex.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589
This mail reflects revision 5 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>
src/openvpn/ssl_verify_openssl.c +16 -6
@@ -260,17 +260,19 @@ }else if (strcmp (LN_serialNumber, x509_username_field) ==0 ) { -ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); -struct gc_arena gc =gc_new (); -char *serial =format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 |FHE_CAPS ,NULL , &gc); +const ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); + +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +char *serial =BN_bn2hex (bn_serial); +BN_free (bn_serial);if (!serial || cn_len <=strlen (serial) +2 ) { -gc_free (&gc); +OPENSSL_free (serial);return FAILURE ; }snprintf (common_name, cn_len,"0x%s" , serial); -gc_free (&gc); +OPENSSL_free (serial); }else {
@@ -315,8 +317,16 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) {const ASN1_INTEGER *asn1_i =X509_get_serialNumber (cert); +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +int len_serial =BN_num_bytes (bn_serial); +unsigned char *buf =malloc (len_serial); +BN_bn2binpad (bn_serial, buf, len_serial); -return format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 ,":" , gc); +char *ret =format_hex_ex (buf, len_serial,0 ,1 ,":" , gc); +free (buf); +BN_free (bn_serial); + +return ret; } result_t
[Openvpn-devel] [PATCH applied] Re: Do not access internals of ASN1_INTEGER to print hex of serial
There was a bit of confusion with the buildbot fails on freebsd 13 - which got fixed by rebasing to current master, some const/non-const openssl 4.0 work fallout. I did not investigate further as the rebased is exactly identical to the v5, just no build fails anymore.
The patch itself passes the corresponding unit test, so it won't crash and won't change user-visible behaviour. Plus, ACK from Frank.
Your patch has been applied to the master and release/2.7 branch.
commit bab0e32e6f9de8ee1433abcaafc4719f170b2f47 (master) commit c3dd2ab23e7e11426d7eedbcdbd97b4fa05bee88 (release/2.7)
Author: Arne Schwabe Date: Sat Apr 4 17:57:19 2026 +0200
Do not access internals of ASN1_INTEGER to print hex of serial
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Frank Lichtenheld <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36459.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: plaisthos.
cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Patch Set 5: Code-Review-1
(1 comment)
Patchset:
PS5:
This still fails -Werror builds on FreeBSD 13 with "OpenSSL 1.1.1w-freebsd 11 Sep 2023".
Not sure how to proceed...? It works without -Werror, so for "people can still use 2.7/master on FreeBSD 13 or earlier" that is good enough...
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Sat, 04 Apr 2026 16:13:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: cron2, plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Patch Set 6: Code-Review+2
(1 comment)
Patchset:
PS5:
Quoted 1 line
This still fails -Werror builds on FreeBSD 13 with "OpenSSL 1.1.1w-freebsd 11 Sep 2023". […]
Rebase "fixed" that since it was caused by an earlier version of a patch still in the branch.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Sat, 04 Apr 2026 20:05:12 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: cron2 <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Patch Set 6: -Code-Review
(1 comment)
Patchset:
PS6:
all green!
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 04 Apr 2026 20:10:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: flichtenheld.
cron2 has uploaded a new patch set (#7) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Do not access internals of ASN1_INTEGER to print hex of serial
OpenSSL 4.0 does not allow internal access to to these data structures anymore. So use public methods to get the serial data and convert it to hex.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36459.html
---
M src/openvpn/ssl_verify_openssl.c
1 file changed, 16 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/1589/7
src/openvpn/ssl_verify_openssl.c +16 -6
@@ -260,17 +260,19 @@ }else if (strcmp (LN_serialNumber, x509_username_field) ==0 ) { -ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); -struct gc_arena gc =gc_new (); -char *serial =format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 |FHE_CAPS ,NULL , &gc); +const ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); + +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +char *serial =BN_bn2hex (bn_serial); +BN_free (bn_serial);if (!serial || cn_len <=strlen (serial) +2 ) { -gc_free (&gc); +OPENSSL_free (serial);return FAILURE ; }snprintf (common_name, cn_len,"0x%s" , serial); -gc_free (&gc); +OPENSSL_free (serial); }else {
@@ -315,8 +317,16 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) {const ASN1_INTEGER *asn1_i =X509_get_serialNumber (cert); +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +int len_serial =BN_num_bytes (bn_serial); +unsigned char *buf =malloc (len_serial); +BN_bn2binpad (bn_serial, buf, len_serial); -return format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 ,":" , gc); +char *ret =format_hex_ex (buf, len_serial,0 ,1 ,":" , gc); +free (buf); +BN_free (bn_serial); + +return ret; } result_t
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
[Openvpn-devel] [S] Change in openvpn[master]: Do not access internals of ASN1_INTEGER to print hex of serial
In reply to a message not in the archiveAttention is currently required from: flichtenheld.
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email )
Change subject: Do not access internals of ASN1_INTEGER to print hex of serial
......................................................................
Do not access internals of ASN1_INTEGER to print hex of serial
OpenSSL 4.0 does not allow internal access to to these data structures anymore. So use public methods to get the serial data and convert it to hex.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1589
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36459.html
---
M src/openvpn/ssl_verify_openssl.c
1 file changed, 16 insertions(+), 6 deletions(-)
src/openvpn/ssl_verify_openssl.c +16 -6
@@ -260,17 +260,19 @@ }else if (strcmp (LN_serialNumber, x509_username_field) ==0 ) { -ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); -struct gc_arena gc =gc_new (); -char *serial =format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 |FHE_CAPS ,NULL , &gc); +const ASN1_INTEGER *asn1_i =X509_get_serialNumber (peer_cert); + +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +char *serial =BN_bn2hex (bn_serial); +BN_free (bn_serial);if (!serial || cn_len <=strlen (serial) +2 ) { -gc_free (&gc); +OPENSSL_free (serial);return FAILURE ; }snprintf (common_name, cn_len,"0x%s" , serial); -gc_free (&gc); +OPENSSL_free (serial); }else {
@@ -315,8 +317,16 @@ backend_x509_get_serial_hex(openvpn_x509_cert_t *cert, struct gc_arena *gc) {const ASN1_INTEGER *asn1_i =X509_get_serialNumber (cert); +BIGNUM *bn_serial =ASN1_INTEGER_to_BN (asn1_i,NULL ); +int len_serial =BN_num_bytes (bn_serial); +unsigned char *buf =malloc (len_serial); +BN_bn2binpad (bn_serial, buf, len_serial); -return format_hex_ex (ASN1_STRING_get0_data (asn1_i),ASN1_STRING_length (asn1_i),0 ,1 ,":" , gc); +char *ret =format_hex_ex (buf, len_serial,0 ,1 ,":" , gc); +free (buf); +BN_free (bn_serial); + +return ret; } result_t
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1589?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5158fbb0762443ea4954e5745f520e83e019ed30
Gerrit-Change-Number: 1589
Gerrit-PatchSet: 7
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>